#ifndef __SHADER_HPP__
#define __SHADER_HPP__ 1

#include <algorithm>
#include <vector>

#include "GL/glew.h"

struct Shader
{
	GLenum shaderType;
	GLenum shaderBit;
	GLuint shaderId;
	std::string file;
	std::vector<GLint> uniforms;
};

struct ShaderProgram
{
	ShaderProgram() : pipeline(0) { shaders.reserve(5); }
	~ShaderProgram()
	{
		std::for_each(shaders.begin(), shaders.end(), [&](Shader* shader)
		{
			if(shader)
			{
				::glDeleteProgram(shader->shaderId);
				delete shader;
			}
		});
	}

	GLuint pipeline;
	std::vector<Shader*> shaders;
};

class CShader
{
public:
	bool CreateUniforms(std::vector<std::string> uniforms);
	bool ShaderRead(std::string& shaderFile, char **shaderSource);
	Shader* ShaderCompile(GLenum shaderType, std::string& shaderFile, const char *shaderSource);
	bool GetInfoLog(const std::string& file, GLuint index, GLenum type);
	ShaderProgram* CreateProgram(std::vector<std::string>&& uniforms, std::string&& vertexFile, std::string&& fragFile, std::string&& geomFile, std::string&& tessControlFile, std::string&& tessEvalFile);
};

#endif